//
//  YSCommentMsgFrame.m
//  Yueshi
//
//  Created by yueshi－mac1 on 15/12/7.
//  Copyright © 2015年 悦食中国. All rights reserved.
//

#import "YSCommentMsgFrame.h"

@implementation YSCommentMsgFrame

- (void)setCommentMsg:(YSCommentMsg *)commentMsg{
    _commentMsg = commentMsg;
    
    //postName
    CGSize postNameSize = [commentMsg.postName sizeWithFont:SYS_FONT(postNameFont)];
    _postNameFrame = CGRectMake(YSPublicXInset, YSPublicXInset, postNameSize.width, postNameSize.height);
    
    //avatar
    _avatarFrame = CGRectMake(YSPublicXInset, CGRectGetMaxY(_postNameFrame)+YSPublicXInset, 100/2, 100/2);
    
    //username
    CGSize userNameSize = [commentMsg.commentName sizeWithFont:SYS_FONT(userNameFont)];
    _userNameFrame = CGRectMake(CGRectGetMaxX(_avatarFrame) + YSPublicXInset, CGRectGetMinY(_avatarFrame) + 12, userNameSize.width, userNameSize.height);
    
    //time
    CGSize timeSize = [commentMsg.commentTime sizeWithFont:SYS_FONT(timeFont)];
    _timeFrame = CGRectMake(SCREENW-timeSize.width-YSPublicXInset, CGRectGetMaxY(_userNameFrame)-timeSize.height, timeSize.width, timeSize.height);
    
    //content
    CGSize contentSize = [_commentMsg.commentContent sizeWithFont:SYS_FONT(contentFont) constrainedToSize:CGSizeMake(SCREENW-YSPublicXInset - CGRectGetMinX(_userNameFrame), MAXFLOAT)];
    _contentFrame = CGRectMake(CGRectGetMinX(_userNameFrame), CGRectGetMaxY(_userNameFrame)+12, contentSize.width, contentSize.height);
    
    _spliteFrame = CGRectMake(0, CGRectGetMaxY(_contentFrame)+YSPublicXInset, SCREENW, YSPublicXInset);
    
    _cellHeight = CGRectGetMaxY(_spliteFrame);
    
    _frame = CGRectMake(0, 0, SCREENW, _cellHeight);
    
}

@end
